home *** CD-ROM | disk | FTP | other *** search
- /* (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
- *
- * Redistribution and use in source and binary forms are permitted for
- * non-commercial use, provided that the above copyright notice and this
- * paragraph are duplicated in all such forms. THIS SOFTWARE IS PROVIDED
- * ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
- #include <stdio.h>
- #include "screen.h"
-
- mk_auto(fnm)
- unsigned char fnm[];
- {
- FILE *aexec;
- unsigned char buf[128], defrou[5], tmp[10];
-
- if ( (path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\') )
- path[strlen(path)-1] = NULL;
- sprintf(buf, "%s\\%s", path, fnm);
- if (debug)
- {
- printf("***> autoexec.net file (%s):\n", buf);
- aexec = stdout;
- }
- else
- {
- if ( (aexec = fopen(buf, "r")) != NULL )
- {
- printf("\n(%s) already exists, overwrite (y/n)? ",buf);
- scanf("%s", tmp);
- if ( (tmp[0] != 'y') && (tmp[0] != 'Y') )
- {
- fclose(aexec);
- return 0;
- }
- }
- fclose(aexec);
- if ( (aexec = fopen(buf, "w")) == NULL )
- {
- printf("\nCan't open \"%s\" for write, aborting!\n\n", buf);
- exit(-1);
- }
- }
-
- if (g1emm)
- fprintf(aexec, "# A U T O E X E C . N E T F O R N O S ( G 1 E M M )\n");
- else
- fprintf(aexec, "# A U T O E X E C . N E T F O R N O S\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Local Definitions\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "hostname %s\n", callsign);
- fprintf(aexec, "ax25 mycall %s\n", callsign);
- fprintf(aexec, "ip address %s\n", callsign);
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Attach ports\n");
- fprintf(aexec, "# ===========================================================================\n");
- if (com1)
- {
- fprintf(aexec, "# COM1: SET UP AS A %ld bps CONNECTION\n",com1spd);
- fprintf(aexec, "attach asy 0x3f8 4 %s ax1 2048 256 %ld\n", com1typ, com1spd);
- }
- if (com2)
- {
- fprintf(aexec, "# COM2: SET UP AS A %ld bps CONNECTION\n",com2spd);
- fprintf(aexec, "attach asy 0x2f8 3 %s ax2 2048 256 %ld\n", com2typ, com2spd);
- }
- if (com3)
- {
- fprintf(aexec, "# COM3: SET UP AS A %ld bps CONNECTION\n",com3spd);
- fprintf(aexec, "attach asy 0x3e8 4 %s ax3 2048 256 %ld\n", com3typ, com3spd);
- }
- if (com4)
- {
- fprintf(aexec, "# COM4: SET UP AS A %ld bps CONNECTION\n",com4spd);
- fprintf(aexec, "attach asy 0x2e8 3 %s ax4 2048 256 %ld\n", com4typ, com4spd);
- }
- if (drsi_0 && !drsi_1)
- {
- fprintf(aexec, "# DRSI first port only init\n");
- fprintf(aexec, "attach scc 1 init 300 16 2 0 1 0 7 p4915200 8\n");
- fprintf(aexec, "attach scc 0 %s da0 256 d%ld 1024 %s\n", drsi_0typ, drsi_0spd, callsign);
- }
- if (!drsi_0 && drsi_1)
- {
- fprintf(aexec, "# DRSI second port only init\n");
- fprintf(aexec, "attach scc 1 init 300 16 2 0 1 0 7 p4915200 8\n");
- fprintf(aexec, "attach scc 1 %s da1 256 d%ld 1024 %s\n", drsi_1typ, drsi_1spd, callsign);
- }
- if (drsi_0 && drsi_1)
- {
- fprintf(aexec, "# DRSI two port init\n");
- fprintf(aexec, "attach scc 2 init 300 16 2 0 1 0 7 p4915200 8\n");
- fprintf(aexec, "attach scc 0 %s da0 256 d%ld 1024 %s\n", drsi_0typ, drsi_0spd, callsign);
- fprintf(aexec, "attach scc 1 %s da1 256 d%ld 1024 %s\n", drsi_1typ, drsi_1spd, callsign);
- }
- if (pc100_0 && !pc100_1)
- {
- fprintf(aexec, "# PC100-series first port only init\n");
- fprintf(aexec, "attach scc 1 init 220 16 6 4 1 0 2 p4915200 2 02\n");
- fprintf(aexec, "attach scc 0 %s pa0 256 d%ld 1024 %s\n", pc100_0typ, pc100_0spd, callsign);
- }
- if (!pc100_0 && pc100_1)
- {
- fprintf(aexec, "# PC100-series second port only init\n");
- fprintf(aexec, "attach scc 1 init 220 16 6 4 1 0 2 p4915200 2 02\n");
- fprintf(aexec, "attach scc 1 %s pa1 256 d%ld 1024 %s\n", pc100_1typ, pc100_1spd, callsign);
- }
- if (pc100_0 && pc100_1)
- {
- fprintf(aexec, "# PC100-series two port init\n");
- fprintf(aexec, "attach scc 2 init 220 16 6 4 1 0 2 p4915200 2 02\n");
- fprintf(aexec, "attach scc 0 %s pa0 256 d%ld 1024 %s\n", pc100_0typ, pc100_0spd, callsign);
- fprintf(aexec, "attach scc 1 %s pa1 256 d%ld 1024 %s\n", pc100_1typ, pc100_1spd, callsign);
- }
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Set comm parameters\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# <KISS param 1> = TX Delay (10mS units):\n");
- fprintf(aexec, "# <KISS param 2> = Persist (1/256th units):\n");
- fprintf(aexec, "# <KISS param 3> = Slot time (10mS units):\n");
- fprintf(aexec, "# <KISS param 4> = TX-tail Delay (10mS units):\n");
- fprintf(aexec, "# <KISS param 5> = Duplex (0=half, 1=full):\n");
- if (com1)
- {
- if ( ((com1typ[0] == 'a') || (com1typ[0] == 'A'))
- && ((com1typ[1] == 'x') || (com1typ[1] == 'X'))
- && (com1typ[2] == '2') && (com1typ[3] == '5') )
- {
- fprintf(aexec, "param ax1 1 45\n");
- fprintf(aexec, "param ax1 2 33\n");
- fprintf(aexec, "param ax1 3 18\n");
- fprintf(aexec, "param ax1 4 20\n");
- fprintf(aexec, "param ax1 5 0\n");
- }
- fprintf(aexec, "mode ax1 datagram\n");
- }
- if (com2)
- {
- if ( ((com2typ[0] == 'a') || (com2typ[0] == 'A'))
- && ((com2typ[1] == 'x') || (com2typ[1] == 'X'))
- && (com2typ[2] == '2') && (com2typ[3] == '5') )
- {
- fprintf(aexec, "param ax2 1 45\n");
- fprintf(aexec, "param ax2 2 33\n");
- fprintf(aexec, "param ax2 3 18\n");
- fprintf(aexec, "param ax2 4 20\n");
- fprintf(aexec, "param ax2 5 0\n");
- }
- fprintf(aexec, "mode ax2 datagram\n");
- }
- if (com3)
- {
- if ( ((com3typ[0] == 'a') || (com3typ[0] == 'A'))
- && ((com3typ[1] == 'x') || (com3typ[1] == 'X'))
- && (com3typ[2] == '2') && (com3typ[3] == '5') )
- {
- fprintf(aexec, "param ax3 1 45\n");
- fprintf(aexec, "param ax3 2 33\n");
- fprintf(aexec, "param ax3 3 18\n");
- fprintf(aexec, "param ax3 4 20\n");
- fprintf(aexec, "param ax3 5 0\n");
- }
- fprintf(aexec, "mode ax3 datagram\n");
- }
- if (com4)
- {
- if ( ((com4typ[0] == 'a') || (com4typ[0] == 'A'))
- && ((com4typ[1] == 'x') || (com4typ[1] == 'X'))
- && (com4typ[2] == '2') && (com4typ[3] == '5') )
- {
- fprintf(aexec, "param ax4 1 45\n");
- fprintf(aexec, "param ax4 2 33\n");
- fprintf(aexec, "param ax4 3 18\n");
- fprintf(aexec, "param ax4 4 20\n");
- fprintf(aexec, "param ax4 5 0\n");
- }
- fprintf(aexec, "mode ax4 datagram\n");
- }
- if (drsi_0)
- fprintf(aexec, "mode da0 datagram\n");
- if (drsi_1)
- fprintf(aexec, "mode da1 datagram\n");
- if (pc100_0)
- fprintf(aexec, "mode pa0 datagram\n");
- if (pc100_1)
- fprintf(aexec, "mode pa1 datagram\n");
- fprintf(aexec, "ip ttl 16\n");
- fprintf(aexec, "tcp mss 216\n");
- fprintf(aexec, "tcp window 216\n");
- fprintf(aexec, "tcp irtt 30000\n");
- fprintf(aexec, "ax25 paclen 256\n");
- fprintf(aexec, "ax25 window 256\n");
- fprintf(aexec, "ax25 digipeat on\n");
- fprintf(aexec, "ax25 maxframe 1\n");
- fprintf(aexec, "ax25 retry 5\n");
- fprintf(aexec, "ax25 irtt 5000\n");
- fprintf(aexec, "ax25 blimit 7\n");
- fprintf(aexec, "ax25 version 2\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Start Servers\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "start ax25\n");
- if (nr_rqd)
- fprintf(aexec, "start netrom\n");
- fprintf(aexec, "start ttylink\n");
- fprintf(aexec, "start echo\n");
- fprintf(aexec, "start discard\n");
- fprintf(aexec, "start telnet\n");
- fprintf(aexec, "start ftp\n");
- fprintf(aexec, "start smtp\n");
- fprintf(aexec, "start finger\n");
- fprintf(aexec, "start remote\n");
- if (nr_rqd)
- {
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Netrom\n");
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "attach netrom\n");
- sprintf(buf, "%2.2lx%2.2lx%2.2lx", ((ip >> 16) & 0xff),
- ((ip >> 8) & 0xff), (ip & 0xff) );
- buf[0] = (unsigned char)toupper( (unsigned int)buf[0] );
- buf[1] = (unsigned char)toupper( (unsigned int)buf[1] );
- buf[2] = (unsigned char)toupper( (unsigned int)buf[2] );
- buf[3] = (unsigned char)toupper( (unsigned int)buf[3] );
- buf[4] = (unsigned char)toupper( (unsigned int)buf[4] );
- buf[5] = (unsigned char)toupper( (unsigned int)buf[5] );
- fprintf(aexec, "netrom nodetimer 1200\n");
- fprintf(aexec, "netrom obsotimer 3600\n");
- fprintf(aexec, "netrom ttl 15\n");
- fprintf(aexec, "netrom retries 5\n");
- fprintf(aexec, "netrom irtt 30000\n");
- fprintf(aexec, "netrom window 1\n");
- fprintf(aexec, "netrom verbose no\n");
- fprintf(aexec, "mode netrom vc\n");
- if (com1)
- {
- fprintf(aexec, "netrom interface ax1 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes ax1\n");
- }
- if (com2)
- {
- fprintf(aexec, "netrom interface ax2 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes ax2\n");
- }
- if (com3)
- {
- fprintf(aexec, "netrom interface ax3 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes ax3\n");
- }
- if (com4)
- {
- fprintf(aexec, "netrom interface ax4 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes ax4\n");
- }
- if (drsi_0)
- {
- fprintf(aexec, "netrom interface da0 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes da0\n");
- }
- if (drsi_1)
- {
- fprintf(aexec, "netrom interface da1 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes da1\n");
- }
- if (pc100_0)
- {
- fprintf(aexec, "netrom interface pa0 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes pa0\n");
- }
- if (pc100_1)
- {
- fprintf(aexec, "netrom interface pa1 %s 255\n", buf);
- fprintf(aexec, "netrom bcnodes pa1\n");
- }
- }
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Routing\n");
- fprintf(aexec, "# ===========================================================================\n");
- if (com1)
- strcpy(defrou, "ax1");
- else if (com2)
- strcpy(defrou, "ax2");
- else if (com3)
- strcpy(defrou, "ax3");
- else if (com4)
- strcpy(defrou, "ax4");
- else if (drsi_0)
- strcpy(defrou, "da0");
- else if (drsi_1)
- strcpy(defrou, "da1");
- else if (pc100_0)
- strcpy(defrou, "pa0");
- else if (pc100_1)
- strcpy(defrou, "pa1");
- fprintf(aexec, "route addprivate default %s", defrou);
- if (gate_rqd)
- fprintf(aexec, " [%ld.%ld.%ld.%ld]\n", ((gateway >> 24) & 0xff),
- ((gateway >> 16) & 0xff), ((gateway >> 8) & 0xff),
- (gateway & 0xff), callsign);
- else
- fprintf(aexec, "\n");
- if (g1emm)
- {
- fprintf(aexec, "# ========================================================================\n");
- fprintf(aexec, "# RSPF configuration\n");
- fprintf(aexec, "# ========================================================================\n");
- fprintf(aexec, "#ifconfig %s broadcast [%ld.%ld.255.255]\n",
- defrou, ((ip >> 24) & 0xff),
- ((ip >> 16) & 0xff) );
- fprintf(aexec, "#rspf interface %s 8 32\n", defrou);
- fprintf(aexec, "#rspf rrhtimer 1800\n");
- fprintf(aexec, "#rspf suspecttimer 4000\n");
- fprintf(aexec, "#rspf timer 1800\n");
- fprintf(aexec, "#rspf message \"KA9Q TCP/IP RSPF Routing -- Share and Enjoy!!\"\n");
- }
- fprintf(aexec, "# ===========================================================================\n");
- fprintf(aexec, "# Misc\n");
- fprintf(aexec, "# ===========================================================================\n");
- if (g1emm)
- {
- fprintf(aexec, "mem eff on\n");
- fprintf(aexec, "multi off\n");
- fprintf(aexec, "motd \"If no one answers, escape back to the Mbox, and leave a message\"\n");
- fprintf(aexec, "attend on\n");
- fprintf(aexec, "tcp timer linear\n");
- fprintf(aexec, "ax25 timer linear\n");
- if (nr_rqd)
- fprintf(aexec, "netrom timer linear\n");
- fprintf(aexec, "domain cache size 15\n");
- fprintf(aexec, "domain translate off\n");
- fprintf(aexec, "domain verbose off\n");
- }
- if (rmt_pass)
- fprintf(aexec, "remote -s %s\n", password);
- fprintf(aexec, "log nos.log\n");
- fprintf(aexec, "smtp timer 1800\n");
- fprintf(aexec, "smtp trace 0\n");
- fprintf(aexec, "smtp maxclients 7\n");
- fprintf(aexec, "smtp batch on\n");
- fprintf(aexec, "mbox motd \"IP ==> [%ld.%ld.%ld.%ld] Leave msg using: S %s\"\n",
- ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), ((ip >> 8) & 0xff),
- (ip & 0xff), callsign);
- fprintf(aexec, "mbox attend on\n");
-
- if (!debug)
- fclose(aexec);
- }
-